package com.slkj.shilixiaoyuanapp.entity;

import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.view.View;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.slkj.shilixiaoyuanapp.entity.base.BaseChoseEntity;
import com.slkj.shilixiaoyuanapp.ui.common.adapter.SendObjAdapter;
import com.slkj.shilixiaoyuanapp.ui.teacher.tool.MyApproval.MyApprovalHistoryFragment;

import net.sourceforge.pinyin4j.PinyinHelper;

import java.io.Serializable;
import java.util.HashMap;

import me.zhouzhuo.zzletterssidebar.anotation.Letter;

/**
 * Created  on 2018-08-01
 *
 * @author 唐开阔
 * @describe 人员实体
 */
public class PeopleEntity extends BaseChoseEntity implements Parcelable, MultiItemEntity {

    protected PeopleEntity(Parcel in) {
        uId = in.readInt();
        uName = in.readString();
        headImg = in.readString();
        headRes = in.readInt();
        state = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(uId);
        dest.writeString(uName);
        dest.writeString(headImg);
        dest.writeInt(headRes);
        dest.writeInt(state);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<PeopleEntity> CREATOR = new Creator<PeopleEntity>() {
        @Override
        public PeopleEntity createFromParcel(Parcel in) {
            return new PeopleEntity(in);
        }

        @Override
        public PeopleEntity[] newArray(int size) {
            return new PeopleEntity[size];
        }
    };

    public int getHeadRes() {
        return headRes;
    }

    public void setHeadRes(int headRes) {
        this.headRes = headRes;
    }

    /**
     * uId : 4
     * uName : 邓平平
     */

    private int uId;
    @Letter(isSortField = true)
    private String uName;
    private String headImg;
    private int headRes;
    private int state;

    public PeopleEntity(String uName) {
        this.uName = uName;
        uId = -1;
    }
    public PeopleEntity(String uName, int uId) {
        this.uName = uName;
        this.uId = uId;
    }

    public String getStateStr() {
        switch (state) {
            case MyApprovalHistoryFragment.TYPE_NOT_LOOK:
                return "待审批";
            case MyApprovalHistoryFragment.TYPE_REFUSE:
                return "未通过";
            case MyApprovalHistoryFragment.TYPE_OK:
                return "已通过";
        }
        return "";
    }

    public int getTypeColor() {
        int color = 0;
        switch (state) {
            case 0:
                color = Color.parseColor("#999999");
                break;
            case 1:
                color = Color.parseColor("#FF6953");

                break;
            case 2:
                color = Color.parseColor("#0087FC");

                break;
        }
        return color;
    }



    public int getuId() {
        return uId;
    }

    public void setuId(int uId) {
        this.uId = uId;
    }



    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    public int getUId() {
        return uId;
    }

    public void setUId(int uId) {
        this.uId = uId;
    }

    public String getUName() {
        return uName;
    }

    public void setUName(String uName) {
        this.uName = uName;
    }


    @Override
    public int getItemType() {
        return uId == -1? SendObjAdapter.TYPE_LEVEL_0 : SendObjAdapter.TYPE_PERSON;
    }
}
